import {
	createRouter,
	createWebHistory
} from 'vue-router'
import HomeView from '../views/HomeView.vue'


const router = createRouter({
	history: createWebHistory(import.meta.env.BASE_URL),
	routes: [
		{
			path: '/',
			name: 'home',
			component: HomeView,
			redirect:"/index",
			children:[
				{
					path:"/index",
					component:()=>import("../views/Index.vue")
				},
				{
					path:"/marketSys",
					component:()=>import("../views/marketSys.vue"),
				},
				{
					path:"/vip",
					component:()=>import("../views/vip.vue")
				},
				{
					path:"/marketSys/about",
					component:()=>import("../views/about.vue"),
				},
				{
					path:"/vip/viplist",
					component:()=>import("../views/viplist.vue"),
				},
				
			]
		},
		{
			path: '/login',
			name: 'login',
			component: () => import('../views/Login.vue'),
		},
		
		
	]
})
router.beforeEach((to,from)=>{
	if(to.name!="login" && !sessionStorage.getItem("token")){
		return {
			name:"login"
		}
	}
})



export default router